#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int a[20];
int main() {
    int n = 0;
    scanf("%d", &n);
    int cn = 0;
    while (1)
    {
        if (n == 0)
        {
            break;
        }
        a[cn] = n % 6;
        cn++;
        n /= 6;
    }
    for (int i = cn - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
    }
    return 0;
}